package com.community;

import com.community.service.DictService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Service;

import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;

@Service
public class ScheduleTasks implements ApplicationRunner {

    private static ScheduledExecutorService executor = Executors.newScheduledThreadPool(10);

    public void execute(Runnable task){
        executor.execute(task);
    }

    @Autowired
    private DictService dictService;

    @Override
    public void run(ApplicationArguments args) throws Exception {
        dictService.initThresholdMap();

    }
}
